import App from './App'



// #ifndef VUE3
import Vue from 'vue'
// 如此配置即可

function isLogin (isAuth = false) {
	const userInfo = uni.getStorageSync('sc-userInfo');
	if (isAuth && !userInfo.mobile) {
		uni.showModal({
			title: '提示',
			content: '你还没有登录，是否前去登录?',
			confirmText: '前往',
			success: function(res) {
				if (res.confirm) {
					uni.navigateTo({
						url: '/pages/login/login',
					})
				}
			}
		});
	} else {
		return !(userInfo.mobile == '' || userInfo.mobile == null)
	}
}
Vue.prototype.$isLogin = isLogin;

Vue.prototype.$goPage = (res, type = 'navigateTo', isAuth = false) => {
	console.log(res,type,isAuth);
	try {
		if (isAuth && isLogin(true)) {
			uni[type]({
				...res
			});
		} else if (!isAuth) {
			uni[type]({
				...res 
			});
		}
	} catch (e) {
		console.log(e);
		// error
	}
} 

// 预览图片
Vue.prototype.$previewImage = (index, urls = []) => {
	uni.previewImage({
		urls,
		current: index,
		indicator: 'default',
		loop: true
	})
} 

Vue.prototype.$success = (title, icon = 'none') => {
	uni.showToast({
		title,
		duration: 2000,
		icon
	});
};




import './uni.promisify.adaptor'
// Vue.config.productionTip = false


import api from '@/common/vmeitime-http/'
// 全局挂载后使用
Vue.prototype.$api = api


import share from "./utils/share.js" // 分享文件 文件位置看具体目录
Vue.mixin(share)

App.mpType = 'app'
const app = new Vue({
	...App,
	share
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif